import * as XcUtil from '@/utils/xcutil.js'
export default {
  namespaced: true,
  state: {
    buildingList: XcUtil.getStorageJson("buildingList") || [],
    floorList: XcUtil.getStorageJson("floorList") || [],
    merchantList: XcUtil.getStorageJson("merchantList") || [],
    elevatorList: XcUtil.getStorageJson("elevatorList") || [],
    roomList: XcUtil.getStorageJson("roomList") || [],
    parkSpaceList: XcUtil.getStorageJson("parkSpaceList") || [],
    utilitieList: XcUtil.getStorageJson("utilitieList") || [],
    utilitieTypeList: XcUtil.getStorageJson("utilitieTypeList") || [],
    meshList: XcUtil.getStorageJson("meshList") || [],
    makerList: XcUtil.getStorageJson("makerList") || [],
    fenceList: XcUtil.getStorageJson("fenceList") || [],
    areaList: XcUtil.getStorageJson("areaList") || [],
    ibeaconsMap: XcUtil.getStorageJson("ibeaconsMap") || {},
    unreadAlarmCount: 0
  },
  mutations: {
    updateBuildingList (state, val) {
      XcUtil.setStorage("buildingList", JSON.stringify(val))
      state.buildingList = val || []
    },
    updateIbeaconsMap (state, val) {
      XcUtil.setStorage("ibeaconsMap", JSON.stringify(val))
      state.ibeaconsMap = val || {}
    },
    updateFloorList (state, val) {
      XcUtil.setStorage("floorList", JSON.stringify(val))
      state.floorList = val || []
    },
    updateMerchantList (state, val) {
      XcUtil.setStorage("merchantList", JSON.stringify(val))
      state.merchantList = val || []
    },
    updateElevatorList (state, val) {
      XcUtil.setStorage("elevatorList", JSON.stringify(val))
      state.elevatorList = val || []
    },
    updateParkSpaceList (state, val) {
      XcUtil.setStorage("parkSpaceList", JSON.stringify(val))
      state.parkSpaceList = val || []
    },
    updateUtilitieList (state, val) {
      XcUtil.setStorage("utilitieList", JSON.stringify(val))
      state.utilitieList = val || []
    },
    updateUtilitieTypeList (state, val) {
      XcUtil.setStorage("utilitieTypeList", JSON.stringify(val))
      state.utilitieTypeList = val || []
    },
    updateRoomList (state, val) {
      XcUtil.setStorage("roomList", JSON.stringify(val))
      state.roomList = val || []
    },
    updateFenceList (state, val) {
      XcUtil.setStorage("fenceList", JSON.stringify(val))
      state.fenceList = val || []
    },
    updateAreaList (state, val) {
      XcUtil.setStorage("areaList", JSON.stringify(val))
      state.areaList = val || []
    },
    updateMeshList (state, val) {
      XcUtil.setStorage("meshList", JSON.stringify(val))
      state.meshList = val || []
    },
    updateMakerList (state, val) {
      XcUtil.setStorage("makerList", JSON.stringify(val))
      state.makerList = val || []
    },
    updateUnreadAlarmCount (state, val) {
      state.unreadAlarmCount = val || 0
    }
  }
}
